﻿CREATE TABLE [Projects].[datProjects] (
    [ProjectID]          INT             IDENTITY (1, 1) NOT NULL,
    [Intern]             BIT             CONSTRAINT [DF_datProjects_Intern] DEFAULT ((0)) NOT NULL,
    [ShortName]          NVARCHAR (50)   NOT NULL,
    [PurchaserID]        INT             NOT NULL,
    [InvoiceToID]        INT             NOT NULL,
    [FirstContactDate]   DATETIME2 (7)   NOT NULL,
    [FirstContactUserID] INT             NOT NULL,
    [Address]            NVARCHAR (50)   NOT NULL,
    [EPLZ]               INT             NOT NULL,
    [ImplementationDate] DATETIME2 (7)   NOT NULL,
    [CustomerSource]     INT             NOT NULL,
    [CustomerGroup]      TINYINT         NOT NULL,
    [CalculationUserID]  INT             NOT NULL,
    [SalesUserID]        INT             NOT NULL,
    [FileUserID]         INT             NOT NULL,
    [CreateOn]           DATETIME2 (7)   NOT NULL,
    [CreateBy]           INT             NOT NULL,
    [LastChangedOn]      DATETIME2 (7)   NOT NULL,
    [LastChangedBy]      INT             NOT NULL,
    [ProjectStatus]      TINYINT         NOT NULL,
    [OrderDate]          DATETIME2 (7)   NULL,
    [FinishDate]         DATETIME2 (7)   NULL,
    [FilePath]           NVARCHAR (255)  NULL,
    [Distance]           DECIMAL (11, 2) CONSTRAINT [DF_datProjects_Distance] DEFAULT ((0)) NOT NULL,
    [Saved]              BIT             CONSTRAINT [DF_datProjects_Saved] DEFAULT ((1)) NOT NULL,
    CONSTRAINT [PK_datProjects] PRIMARY KEY CLUSTERED ([ProjectID] ASC),
    CONSTRAINT [FK_datProjects_domProjectStatus] FOREIGN KEY ([ProjectStatus]) REFERENCES [Projects].[domProjectStatus] ([ProjectStatus])
);










GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_Projects_datProjects_ShortName]
    ON [Projects].[datProjects]([ShortName] ASC);

